import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Lesson extends Thread {
    private Socket socket;

    public Lesson(Socket socket) {
        this.socket = socket;
       // System.out.println("1");
    }


    @Override
    public synchronized void start() {
        super.start();
    }

    @Override
    public void run() {
        super.run();

            try (
                    InputStream is=socket.getInputStream();
                    InputStreamReader isr=new InputStreamReader(is, StandardCharsets.UTF_8);
                    BufferedReader br=new BufferedReader(isr);
                    ){
                System.out.println("输入流连接成功");
                String line;
                while (true) {
                    if ((line= br.readLine())!=null) {
                        System.out.println(line);

                    }
                    Thread.sleep(500);
                }
            }catch (IOException | InterruptedException e){
                System.out.println(e.getMessage()+12);
            }

    }
}
